//
// Created by tan90 on 25-4-27.
//

#include <stdio.h>

/**
 * 指针加减运算
 * @return
 */
int main() {
    char *c = NULL;
    short *p1 = (short *) 0x1234;
    short *p2 = (short *) 0x1238;
    ptrdiff_t i = p2 - p1;
    printf("%llu\n", i);

    int arr[5] = {1, 2, 3, 4, 5};

    int *a0 = &arr[0];
    int *a1 = &arr[3];
    ptrdiff_t i1 = a1 - a0;
    printf("%llu\n", i1);

    int arr1[5] = {1, 2, 3, 4, 5};

    int *p3 = arr1;
    *p3 += 2;
    printf("%d\n", *p3);

    int arr2[5] = {0};
    int *p = arr2;
    for (int i2 = 0; i2 < 5; i2++, p++) {
        *p = i2;
        printf("%d %p\n", *p, p);
    }
}
